package com.zc.topmod.handler;

import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

/**
 * Created by zhucan on 19/2/3.
 */
@Component
@Slf4j
public class TopModCalHandler {

    public Mono<ServerResponse> topModCal(ServerRequest request) {
        Mono<String> mono = request.bodyToMono(String.class);
        log.info("接受支付结果异步通知:{}", mono);
        return mono.flatMap(str -> {
            if(StringUtils.isEmpty(str)){
                log.warn("请求参数为空！！！！！！");
                return ServerResponse.badRequest().contentType(MediaType.APPLICATION_JSON_UTF8).body(null);
            }
            return ServerResponse.ok()
                    .contentType(MediaType.APPLICATION_JSON_UTF8)
                    .body(null);
        });
    }
}
